# -*- coding: utf-8 -*-

import os
import cgi
import urllib
import sys

from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db
from google.appengine.api import mail
from google.appengine.api import urlfetch
from google.appengine.api.urlfetch_errors import *
from google.appengine.api import users
from google.appengine.ext.db import Key
from google.appengine.ext.db import BadKeyError
from google.appengine.ext.webapp import template
from time import strftime

from baseclass import BaseHandler

class AdPage(BaseHandler):
    def get(self):
        if self.request.get("tag")=="bottom":
            self.response.out.write("<div>All rights reserved by Lin Cai 2008</div>")
        else:
            self.response.out.write("<div>A company</div><div>B company</div>")
        
class MainPage(BaseHandler):
    def get(self):
        template_values = {}
        self.outputTemplate(template_values, "main_view.html")
        #path = os.path.join(os.path.dirname(__file__), 'templates', 'tpl.html')
        #self.response.out.write(template.render(path, {}))        

application = webapp.WSGIApplication(
                                     [('/', MainPage),
                                      ('/ad', AdPage)],
                                     debug=True)
    
def main():
    run_wsgi_app(application)

if __name__ == "__main__":
  main()